package com.tgy.基础学习.Thread.Normal;

/**
 * @author 送你一块二向箔
 * @date 2021/11/08 14:21
 */
public class PriorityThread {
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName()+"------主线程------"+Thread.currentThread().getPriority());

        MyPriority myPriority = new MyPriority();
        Thread thread1 = new Thread(myPriority,"一号线程");
        Thread thread2 = new Thread(myPriority,"二号线程");
        Thread thread3 = new Thread(myPriority,"三号线程");
        Thread thread4 = new Thread(myPriority,"四号线程");
        Thread thread5 = new Thread(myPriority,"五号线程");

        thread1.setPriority(Thread.MAX_PRIORITY);
        thread2.setPriority(Thread.MIN_PRIORITY);
        thread3.setPriority(Thread.NORM_PRIORITY);
        thread4.setPriority(7);
        thread5.setPriority(8);


        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();



        new Thread(()->{
            System.out.println(Thread.currentThread().getName()+"------lambda自建线程------"+Thread.currentThread().getPriority());
        }).start();
    }
}

class MyPriority implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"------普通方法自建线程------"+Thread.currentThread().getPriority());
    }
}
